*************************************************************************************
*																					*
*					ANALYSES MAIN TEXT												*
*																					*
*************************************************************************************

* Author: 	Andreas Jungherr, Matthias Mader, Harald Schoen, and Alexander Wuttke
* Date: 	Dec 17
* Project: 	Context-Driven Attitude Formation:
*			The Difference Between Supporting Free Trade in the Abstract and Supporting Specific Trade Agreements





//////////////////////////////
//Figure 2
//*Bar Graph
//////////////////////////////

label var freetrade_tri "Free trade"
label var att_ttip_1_tri "TTIP"
capture gen data = 1 
designplot 	data freetrade_tri att_ttip_1_tri , stat(count) min(1) max(1) variablelabels recast(hbar) ///
			blabel(1, format(%2.0f) size(vsmall)) ///adding row-wise count-numbers
			ylabel(0 863 "10" 1762 "20" 2589 "30" 3452 "40" 4315 "50" 5178 "60", angle(h)) ytitle("") ///x -label
			t1title("") title("")  ///
			outergap(*12) graphregion(margin(zero))
			
*Manually add break in y-vavlue labels

//////////////////////////////
//Table 3
//Cross-Tabs
//Correlation Matrix
//////////////////////////////

tab2 freetrade_tri att_ttip_1_tri , cell
pwcorr att_ttip_1 freetrade, obs sig




//////////////////////////////
//Table 4
//Regression Table 
/////////////////////////////


*Model I, TTIP
regress att_ttip_1  	$specvalues 	$isco 	$employees	$inc 	$values   	$elitecues	
estimates store m1

*Model I, FreeTrade
regress freetrade  		$specvalues  	$isco 	$employees	$inc	$values 	$elitecues	
estimates store m2

*Model II, TTIP
regress att_ttip_1  	$specvalues 	$isco 				$inc	$values   	$elitecues	
estimates store m3
*FreeTrade

*Model II, FreeTrade
regress freetrade  		$specvalues 	$isco 				$inc 	$values   	$elitecues	
estimates store m4
		
*Modell III, TTIP: Standard model
regress att_ttip_1  	$specvalues  	$isco 						$values 	$elitecues	
estimates store m7

*Modell III, FreeTrade: Standard model
regress freetrade  		$specvalues  	$isco 						$values 	$elitecues	
estimates store m8


esttab m1 m2 m3 m4 m7 m8 using "table 4.rtf", replace ///
		title("Table 4: Comparison of the Determinants of Free Trade and TTIP Attitudes") ///
		mtitles("TTIP" "Free trade"  "TTIP" "Free trade" "TTIP" "Free trade" ) ///
		nonum nogaps obslast par label ///
		b(2) se(2) ar2(3) nonotes align(l) ///
		addnotes("Notes: Reported are linear regression coefficients with standard errors in parentheses; Reference category of PI dummies: other/no party; Reference category of skill level dummies: all others; categorical income variable trichotomized; *: p<0,05, **: p<0,01, ***: p<0,001.") /// 
		varwidth(30) modelwidth(3)

//Figure 3
coefplot (m7, label("TTIP") msymbol(Oh)  offset(-0.2))   (m8, label("Free trade")  msymbol(t)  offset(0.3)) , ///
		mcolor(%70) xtitle("") ciopts(recast(rspike) lwidth(thin) color(%70)) msize(medlarge)  xlabel(,labsize(vsmall)) ylabel(,labsize(vsmall)) xline(0, lpattern(shortdash))  ///
		legend(symxsize(*3) symysize(*3) bmargin(zero) ring(0) position(4) region(fcolor(%80))) ///
		headings(isco1_d = `"{it:Economic self-interest}"' freetrade_ego = `"{it:Perceived effects}"' atlanticism = `"{it:Predispositions not directly related to trade}"'  culturalism = `"{it:Openness-related predispositions}"'  pid_cdu_csu_d = `"{it:Elite cues}"' ,labsize(vsmall)) ///Headings
		ysize(18) xsize(17) drop(_cons ) mlabgap(*2) graphregion(margin(small))





//////////////////////////////
//Table 5
//Reporting R2
/////////////////////////////



//////////////////////////////
*Table Model Families
//////////////////////////////


eststo clear
eststo: regress att_ttip_1 	$isco 
eststo: regress att_ttip_1 	$values
eststo: regress att_ttip_1 	$elitecues
eststo: regress att_ttip_1 	freetrade
eststo: regress att_ttip_1 	$specvalues 


esttab est1 est2 est3 est4 est5 using "modelfamilies_ttip.rtf", replace ///
		title("Explanatory Power Model Families: TTIP") ///
		mtitles("Economic self-interest" "Openness-related Predispositions"  "Elite Cues" "Free Trade"  "Predispositions not directly related to trade" ) ///
		nonum nogaps obslast par label ///
		b(2) se(2) ar2(3) nonotes align(l) ///
		addnotes("Notes: Reported are linear regression coefficients with standard errors in parentheses; Reference category of PI dummies: other/no party; Reference category of skill level dummies: all others; categorical income variable trichotomized; *: p<0,05, **: p<0,01, ***: p<0,001.") /// 
		varwidth(20) modelwidth(3)


//////////////////////////////
*Stepwise Regression
//////////////////////////////



eststo clear
eststo: regress att_ttip_1 	$isco 
eststo: regress att_ttip_1 	$isco	$values
eststo: regress att_ttip_1 	$isco	$values	$elitecues
eststo: regress att_ttip_1 	$isco	$values	$elitecues freetrade
eststo: regress att_ttip_1 	$isco	$values	$elitecues freetrade $specvalues 


esttab using "stepwise.rtf", replace ///
		title("Stepwise Regression: TTIP") ///
		mtitles("Objective Self-interest" "+ Openness-related Predispositions" "+ Elite Cues" "+ Free Trade" "+ Predispositions not directly related to trade" ) ///
		nonum nogaps obslast par label ///
		b(2) se(2) ar2(3) nonotes align(l) ///
		addnotes("Notes: Reported are linear regression coefficients with standard errors in parentheses; Reference category of PI dummies: 'other'/'no party'; Reference category of skill level dummies: all others; categorical income variable trichotomized; *: p<0,05, **: p<0,01, ***: p<0,001.") /// 
		varwidth(20) modelwidth(4)
		

////////////////////////////////////////////////////////////
*Footnote 
////////////////////////////////////////////////////////////		

*Differences in Atlanticism between Party Affiliates
sum atlanticism if pid_cdu_d == 1	
sum atlanticism if pid_linke_d == 1	




